<template>
  <div>
    <Row align="middle" justify="center">
      <Col>
        <h1 style="text-align: center; ">卖房信息</h1>
      </Col>
    </Row>
    <Row :gutter="250">
      <Col span="6" offset="10">
        <Button type="info" @click="add(clientId, orderTypeId)">新增</Button>
      </Col>
    </Row>
    <div class="width1190">
      <div class="pro-left">
        <dl v-for="item in saleHouse">
          <dt>
            <div @click="fangsellDetail(item.sellId)">
            	<img :src="item.imgUrl" width="286" height="188"
            	/>
            </div>
          </dt>
          <dd>
            <h3>
              <a href="proinfo.html">{{ item.xiaoqu }}</a>
            </h3>
            <div class="pro-wei">
              <strong class="red">{{ item.zhuangxiu }}</strong>
            </div>
            <div class="pro-fa">产权类型:{{ item.typeName }}</div>
            <div class="pro-fa">发布人：{{ item.personName }}</div>
            <div class="pro-fa">发布时间：{{ item.ct }}</div>
            <Button type="info" @click="change(item.sellId)">修改信息</Button>
            <Button
              type="error"
              @click="remove(item.sellId)"
              style="margin-left: 10px;"
              >删除</Button
            >
          </dd>
          <div class="price">
            ¥<strong>{{ item.totalPrice }}</strong
            ><span class="font12">元</span>
          </div>
          <div class="clears"></div>
        </dl>
        <div class="page">
          <Page
            :page-size="pageSize"
            @on-change="pageSearch"
            :total="total"
            :current="currentPage"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      CarSell: 'light',
      clientId: '',
      saleHouse: [],
      orderTypeId: 1,
	  currentPage: null,
      currentUser:{},
	  pageSize: null,
	  total:null,
      orderInfo: {},
    }
  },
  methods: {
	fangsellDetail:function(sellId){
		this.$router.push({
			name:'house_sale_detail',
			params:{
				sellId
			}
		})
	},
    add: function(clientId, orderTypeId) {
      
      this.$router.push({
        name: 'add_house_sell',
        params: {
          
        },
      })
    },
	pageSearch: function(changedPage) {
	  this.$data.currentPage = changedPage
	  this.search(changedPage)
	},
    search: function(current) {
      this.http
        .get({
          url: '/house-sell-client-vo/page',
          param: { 
			  clientId: this.$data.clientId,
			  pageSize: this.$data.pageSize,
			  currentPage: current
			  },
        })
        .then((data) => {
			this.$data.pageSize = data.size,
			this.$data.currentPage = data.current,
			this.$data.total = data.total,
          this.$data.saleHouse = data.records
          console.log(data)
        })
    },
    change: function(sellId) {
      console.log(sellId)
      this.$router.push({
        name: 'update_house_sale',
        params: {
          sellId,
        },
      })
    },
    remove: function(sellId) {
      this.http
        .delete({
          url: '/house-sell-client-vo/info',
          param: {
            sellId,
          },
        })
        .then((data) => {
          this.message.info('删除成功')
          this.search(1)
        })
    },
  },
  created() {
    this.$data.currentUser = JSON.parse(sessionStorage.getItem('CURRENT'))
    this.$data.clientId = this.$data.currentUser.client.clientId
    this.search(1)

  },
  beforeRouteLeave(to, from, next) {
    this.$destroy() //手动销毁当前页面
    next()
  },
}
</script>

<style></style>
